package day17_Inet.demo07_TCP;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class Clien_TCP {
    public static void main(String[] args) throws Exception{
        //发送数据
        Socket socket = new Socket("192.168.3.172", 8888);
        String s="qubacuishengwang";
        OutputStream os = socket.getOutputStream();
        os.write(s.getBytes());
        //接收数据
        byte[] bytes = new byte[1024];
        InputStream is = socket.getInputStream();
        int i = is.read(bytes);
        System.out.println(new String(bytes,0,i));
        socket.close();
    }
}
